/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   CTimer.h
 * Author: Administrator
 *
 * Created on 2017年9月15日, 下午5:34
 */
#ifndef CTIMER_H_
#define CTIMER_H_
#include"PublicTool.h"
#if USE_PUBLIC_TIMER 
#include <pthread.h>
#include <sys/time.h>
typedef int(*TimerFun)(int);
class PublicTimer{
private:
    pthread_t thread_timer;
    long m_second;
    int m_first;
    static void *OnTimer_stub(void *p){
        (static_cast<PublicTimer*>(p))->thread_proc();
        return NULL;
    }
    void thread_proc();
    void OnTimer();
    TimerFun m_fun;
public:
    PublicTimer();
    PublicTimer(long second);
    virtual ~PublicTimer();
    void SetTimer(long second);
    void StartTimer();
    void StopTimer();
    void SetTimerFun(TimerFun fun);
};
#endif
#endif /* CTIMER_H */

